package com.woniuxy.carlife.carlifenewcomplaintsweb.service.impl;

import com.woniuxy.carlife.carlifecommonsweb.util.CopyUtil;
import com.woniuxy.carlife.carlifenewcomplaintsdomain.dto.MessageCategoryDto;
import com.woniuxy.carlife.carlifenewcomplaintsweb.domain.MessageCategory;
import com.woniuxy.carlife.carlifenewcomplaintsweb.mapper.MessageCategoryMapper;
import com.woniuxy.carlife.carlifenewcomplaintsweb.service.MessageCategoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author yp
 * @ClassName:MessageCategoryServiceImpl
 * @Description:消息类别服务
 * @date 2021/4/7 2:32
 **/
@Service
public class MessageCategoryServiceImpl extends ServiceImpl<MessageCategoryMapper, MessageCategory> implements MessageCategoryService {

    @Resource
    private RedisTemplate redisTemplate;

    @Resource
    private MessageCategoryMapper messageCategoryMapper;

    /*
     * 功能描述〈查询出消息的类别〉
     * @author:yp
     * @param:null
     * @return:List<MessageCategoryDto>
     * @Date 2021/4/10 16:15
     * @throws
     */
    @Override
    public List<MessageCategoryDto> findAll() {
        //List<MessageCategoryDto> list = redisTemplate.opsForList().range("Elist", 0, 1);
        //if (list == null) {
            List<MessageCategory> labelList = messageCategoryMapper.selectList(null);
            //redisTemplate.opsForList().leftPushAll("Elist", labelList);
            List<MessageCategoryDto> list1 = CopyUtil.getList(labelList, MessageCategoryDto.class);
            return list1;
        }
      //  List<MessageCategoryDto> list1 = CopyUtil.getList(list, MessageCategoryDto.class);
       //return list1;
    //}

}
